package view.components
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	
	import global.Resource;
	
	public class TempBitmap extends Bitmap
	{
		private var key:String;
		
		public function TempBitmap(key:String, smoothing:Boolean=false)
		{
			this.key = key;
			super(null,"auto",smoothing);
		}
		
		public function startLoad():void
		{
			this.bitmapData = Resource.getBitmapData(key);
			this.smoothing = this.smoothing;
			this.dispatchEvent(new Event(Event.COMPLETE));
		}
		
		override public function set bitmapData(value:BitmapData) : void
		{
			super.bitmapData = value;
			if (value == null)
			{
				Resource.removeTempBitmap(this);
			}
		}
	}
}